package platzerworld.kegeln.vo.verein;

import platzerworld.kegeln.common.adapter.EqualsUtil;
import platzerworld.kegeln.common.adapter.HashCodeUtil;
import platzerworld.kegeln.vo.KeyValueVO;
import platzerworld.kegeln.vo.klasse.KlasseVO;


/**
 * Value-Object VereinVO
 * 
 * @author platzerg
 */
public class VereinVO extends KeyValueVO{	
	private static final long serialVersionUID = -7306669778620684399L;
  
	public String name;
	
	public int latidute;
	
	public int longitude;
	
	public int clubnummer;
	
	public String club;

	
	public VereinVO(){
		
	}
	
	public VereinVO(long key, String name, int clubnummer, String club){
		this.key = key;
		this.name = name;
		this.clubnummer = clubnummer;
		this.club = club;
	}
	
	public String toString(){
		return this.name;
	}
	
	@Override 
	  public boolean equals(Object otherVereinVO) {
		    if ( this == otherVereinVO ) return true;
		    VereinVO that = (VereinVO)otherVereinVO;

		    return EqualsUtil.areEqual(this.key, that.key);
	  }
	  
	  @Override 
		public int hashCode() {
			 int result = HashCodeUtil.SEED;
			 result = HashCodeUtil.hash( result, key );
			 return result;
		}

		@Override
		public int compareTo(KeyValueVO otherKlasseVO) {
			final int BEFORE = -1;
		    final int EQUAL = 0;
		    final int AFTER = 1;
		    if ( this == otherKlasseVO ) return EQUAL;

		    final KlasseVO compareVO = (KlasseVO) otherKlasseVO;
		    
		    // int comparison = this.name.compareTo(compareVO.name);
		    // if ( comparison != EQUAL ) return comparison;
		    
		    if (this.key < compareVO.key) return BEFORE;
		    if (this.key > compareVO.key) return AFTER;

		    return EQUAL;
		}
	
  /**
   * Zeigt an, ob der Verein bereits gespeichert wurde.
   * 
   * @return true, wenn Verein in Datenbank vorhanden.
   */
  public boolean istNeu() {
    return key == 0;
  }
}
